var o, e = require, t = module, n = exports, i = this && this.__extends || (o = function(e, t) {
    return (o = Object.setPrototypeOf || {
        __proto__: []
    } instanceof Array && function(e, t) {
        e.__proto__ = t;
    } || function(e, t) {
        for (var a in t) t.hasOwnProperty(a) && (e[a] = t[a]);
    })(e, t);
}, function(e, t) {
    function a() {
        this.constructor = e;
    }
    o(e, t), e.prototype = null === t ? Object.create(t) : (a.prototype = t.prototype, 
    new a());
}), a = this && this.__decorate || function(e, t, a, r) {
    var n, i = arguments.length, o = i < 3 ? t : null === r ? r = Object.getOwnPropertyDescriptor(t, a) : r;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) o = Reflect.decorate(e, t, a, r); else for (var s = e.length - 1; 0 <= s; s--) (n = e[s]) && (o = (i < 3 ? n(o) : 3 < i ? n(t, a, o) : n(t, a)) || o);
    return 3 < i && o && Object.defineProperty(t, a, o), o;
};

Object.defineProperty(n, "__esModule", {
    value: !0
});

var r = e("LevelView"), s = e("PersonView"), c = e("AudioManager"), l = e("Global"), d = e("RecorderManager"), u = e("PrefabView"), p = e("PetManager"), h = e("Recorder2View"), f = e("ValueManager"), g = e("GameConfig"), m = e("GameData"), y = e("DataManager"), v = e("WebManager"), w = e("LoadManager"), b = e("UIManager"), P = cc._decorator, I = P.ccclass, G = P.property, _ = function(t) {
    function e() {
        var e = null !== t && t.apply(this, arguments) || this;
        return e.levelView = null, e.personView = null, e.rewardSprite = null, e.sprite = null, 
        e.infoLabel = null, e.nameLabel = null, e.recorderBtn = null, e.nextBtn = null, 
        e.data = [], e.isRecorder = !1, e.isNext = !1, e;
    }
    return i(e, t), e.prototype.onClickRecorder = function() {
        var t = this;
        c.default.getInstance().playAudio("按钮2"), v.default.getInstance().sentLog("TryShareVideo"), 
        GA.isByteDance() && !this.isRecorder && (this.isRecorder = !0, cc.game.pause(), 
        GA.PA.shareAppMessage({
            channel: "video",
            title: "我就要吃鸡",
            desc: "进入吃鸡的世界",
            imageUrl: "",
            templateId: "3eld33adx4d3bk46j6",
            query: "krq_wjycj=10002",
            extra: {
                videoPath: d.default.getInstance().videoPath,
                videoTopics: [ "我就要吃鸡", "卡日曲游戏" ],
                withVideoId: !0,
                createChallenge: !1
            },
            success: function(e) {
                cc.game.resume(), v.default.getInstance().sentLog("ShareVideoSuccess"), t.isRecorder = !1, 
                e.videoId && v.default.getInstance().saveVideoId({
                    aliasId: e.videoId,
                    success: function(e) {
                        console.log("保存视频成功:", e);
                    }
                }), console.log("分享视频成功:", e), t.doReward(), t.doNext();
            },
            fail: function(e) {
                cc.game.resume(), v.default.getInstance().sentLog("ShareVideoFailed"), t.isRecorder = !1, 
                "shareAppMessage:cancel" == e.errMsg || "shareAppMessage:fail video duration is too short" == e.errMsg && b.default.getInstance().showToast({
                    str: "抱歉,录屏时间太短！"
                }), console.log("分享视频失败:", e);
            }
        }));
    }, e.prototype.onClickNext = function() {
        c.default.getInstance().playAudio("按钮2"), v.default.getInstance().sentLog("点击结算1界面录屏取消按键"), 
        3 == g.GC.recorderType ? b.default.getInstance().loadPnl("recorder2", null, function() {
            b.default.getInstance().hideAllPnl();
        }).then(function(e) {
            e instanceof h.default && e.init(f.default.getInstance().getValue("account_reward"));
        }) : (m.GD.recorderCount++, this.doNext());
    }, e.prototype.doReward = function() {
        0 < this.data.length && (this.data.forEach(function(e) {
            switch (e.type) {
              case l.RewardType.DIAMOND:
                m.GD.updateNumber("diamond", e.num);
                break;

              case l.RewardType.SKIN:
                m.GD.addSkin(e.idx) && y.default.getInstance().upload({
                    json: !0,
                    local: !0,
                    skin: e.idx
                }), m.GD.personIdx < e.idx && (m.GD.personIdx = e.idx);
                break;

              case l.RewardType.PET:
                p.default.getInstance().isHas(0) || (p.default.getInstance().getRealData(0).has = 1);
                break;

              case l.RewardType.PIECE:
                m.GD.updateNumber("diamond", e.num);
            }
        }), y.default.getInstance().save(), b.default.getInstance().loadPopPnl("reward", this.data[0]));
    }, e.prototype.doNext = function() {
        b.default.getInstance().hideAllPnl(), b.default.getInstance().showPnl("start");
    }, e.prototype.start = function() {
        this.levelView.refresh(m.GD.level);
        var e = l.G.getRank(m.GD.level).r, t = 100 * (50 + 4 * e);
        this.infoLabel.string = "段位：<color=#ff803b>" + l.G.levelList[e] + "</c>\n胜场：<color=#ff803b>" + m.GD.winTotal + "</c>\n已超越<color=#ff803b>" + (GA.rand(t, 400 + t) / 100).toFixed(2) + "%</c>的玩家";
    }, e.prototype.init = function(e) {
        if (this.data = e, 0 < this.data.length) switch (this.data[0].type) {
          case l.RewardType.DIAMOND:
            this.sprite.node.active = !0, w.default.getInstance().loadSpriteFrame({
                url: "image/ui/钻石奖励",
                sprite: this.sprite
            }), w.default.getInstance().loadSpriteFrame({
                url: "image/ui/钻石奖励",
                sprite: this.rewardSprite
            }), this.nameLabel.string = "钻石 x " + this.data[0].num;
            break;

          case l.RewardType.SKIN:
            this.personView.node.active = !0, this.personView.init(this.data[0].idx), w.default.getInstance().loadSpriteFrame({
                url: "image/skin/" + this.data[0].idx,
                sprite: this.rewardSprite
            }), this.nameLabel.string = l.G.getPersonModel(this.data[0].idx).m;
            break;

          case l.RewardType.PET:
            this.personView.node.active = !0, this.personView.initPet(this.data[0].idx), w.default.getInstance().loadSpriteFrame({
                url: "image/skin3/0",
                sprite: this.rewardSprite
            }), this.nameLabel.string = "机械狗";
            break;

          case l.RewardType.PIECE:
            this.sprite.node.active = !0, w.default.getInstance().loadSpriteFrame({
                url: "image/ui/碎片@2x",
                sprite: this.sprite
            }), w.default.getInstance().loadSpriteFrame({
                url: "image/ui/碎片@2x",
                sprite: this.rewardSprite
            }), this.nameLabel.string = "碎片 x " + this.data[0].num;
        }
    }, a([ G(r.default) ], e.prototype, "levelView", void 0), a([ G(s.default) ], e.prototype, "personView", void 0), 
    a([ G(cc.Sprite) ], e.prototype, "rewardSprite", void 0), a([ G(cc.Sprite) ], e.prototype, "sprite", void 0), 
    a([ G(cc.RichText) ], e.prototype, "infoLabel", void 0), a([ G(cc.Label) ], e.prototype, "nameLabel", void 0), 
    a([ G(cc.Button) ], e.prototype, "recorderBtn", void 0), a([ G(cc.Button) ], e.prototype, "nextBtn", void 0), 
    a([ I ], e);
}(u.default);

n.default = _;